package my.ts.code.net;

import my.ts.code.Config;
import my.ts.code.KLog;
import my.ts.code.objects.SyntaxSms;

public class AppContext {
	public SessionManager session;
	public SyntaxSms syntaxSms;
	//
	public static AppContext instance = new AppContext();
	public boolean connected = false;
	public String currentGameCode = "";
	// user info
	public String username, password;
	public int avatarId;
	public int gender;
	public int balance;

	private AppContext() {
		session = new SessionManager();
		//
		initSmsSyntax();
	}

	private void initSmsSyntax() {
		SyntaxSms ss = new SyntaxSms("AVI", "8791", Config.VIDEO);
	}

	public void connect() throws Exception {
		KLog.log("------------------------------");
		KLog.log("---------- CONNECT ----------");
		KLog.log("------------------------------");
		try {
			Thread.sleep(1500L);
			session.connect();
			connected = true;
		} catch (Exception e) {
			connected = false;
			e.printStackTrace();
			throw e;
		}
	}

	public void close() {
		try {
			connected = false;
			session.disConnect();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
